
 use "$data\analysisdata.dta", clear
 log using "$results\Table1", replace
 gen participated=1 if end_participated_ta==1 
 replace participated=0 if end_participated_ta==3
 replace participated=0 if end_participated_ta==2
 global treatment ITTanalysis participated participatedTA_IVrobust participatedTA_IV

 encode string_strata, generate(stratalottery)
 sort learnerid childwithinHHID
 bysort learnerid round: gen sequence=_n

 ***Table 1 Panel A
 tab ITTanalysis participatedTA_IV if round=="endline" & ITTanalysis~=. & sequence==1


 
 ***Table 1 Panel B 
 use "$data\women_analysis.dta", clear
 global controlkid childageyears female genderage birthorder
 global controlwoman mbase_ageyears  fdstotal rantime ranerror numberkids
 global controlhh land members adults mbase_electrified  mbase_OB mbase_scheduled
 
 reg participatedTA_IV ITTanalysis i.strata $controlkid $controlwoman $controlhh if childageyears<=16, cluster(learnerid)
 reg participatedTA_IV ITTanalysis i.strata $controlwoman $controlhh if sequence==1, vce(robust) coeflegend
 ivregress 2sls Ddays_sick  (participatedTA_IV=ITTanalysis) i.strata $controlkid $controlwoman $controlhh if  childageyears<=16, cluster(learnerid) first
 estat firststage
 ivregress 2sls cover (participatedTA_IV=ITTanalysis) i.strata $controlwoman $controlhh if sequence==1, vce(robust) first
 estat firststage
 
 log close
 exit

































 
